package persistencia;

import java.util.List;

import org.hibernate.SQLQuery;

import dominio.Item;
import dominio.Orcamento;
import persistencia.base.GenericDAOAbstract;

public class OrcamentoDAOImpl extends GenericDAOAbstract<Orcamento, Long>
		implements OrcamentoDAO {

	public Integer verificaId() {
		String sql = "SELECT MAX(id) FROM orcamento";
		SQLQuery sqlQuery = getSession().createSQLQuery(sql);
		return (Integer) sqlQuery.uniqueResult();
	}

	@SuppressWarnings("unchecked")
	public List<Item> buscaItens(int id) {

		String sql = "select * from item_orcamento where idorcamento = " + id;
		SQLQuery sqlQuery = getSession().createSQLQuery(sql).addEntity(Item.class); 
		return sqlQuery.list();
	}

}
